﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BuscoPre.UI.ViewModels;
using BuscoPre.Repository;
using BuscoPre.Domain;


namespace BuscoPre.UI.Controllers
{
	public class SearchController : Controller
	{
		/// <summary>
		/// Cantidad de resultados que se visualizan en la grilla de productos.
		/// </summary>
		private static readonly int Offset = 16;
		
		//
		// GET: /Search/
		public ActionResult Index(string term)
		{
			return View();
		}

		public ActionResult Result(string term)
		{
			var titles = ArticleDao.GetArticlesByQuery(term, Offset);

			var result = new SearchResultViewModel
			{
				Results = titles,
				Title = term,
				Offset = Offset
			};

			return View(result);
		}
	}
}
